﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace CoderJoe.WoW.GearManager
{
	public class CharacterItemModel
		: Model
	{
		public int SlotIndex
		{
			get { return GetValue("SlotIndex", 0); }
			set { SetValue("SlotIndex", value); }
		}
		public int ItemId
		{
			get { return GetValue("ItemId", 0); }
			set { SetValue("ItemId", value); }
		}
		public int[] Gems { get; set; }
		public string Icon
		{
			get { return GetValue("Icon", String.Empty); }
			set { SetValue("Icon", value); }
		}
		public int EnchantId
		{
			get { return GetValue("EnchantId", 0); }
			set { SetValue("EnchantId", value); }
		}
		public int CurrentDurability
		{
			get { return GetValue("CurrentDurability", 0); }
			set { SetValue("CurrentDurability", value); }
		}
		public int Durability
		{
			get { return GetValue("Durability", 0); }
			set { SetValue("Durability", value); }
		}
		public Image Image
		{
			get { return GetValue<Image>("Image", Properties.Resources.ImageLoading); }
			set { SetValue("Image", value); }
		}

		public CharacterItemModel()
		{

		}

		internal void LoadModel(CoderJoe.WoW.Services.CharacterItem characterItem)
		{
			if (characterItem != null)
			{
				ItemId = characterItem.ItemId;
				Icon = characterItem.Icon;
				EnchantId = characterItem.EnchantId;
				CurrentDurability = characterItem.CurrentDurability;
				Durability = characterItem.Durability;
				Image = null;
			}
			else
			{
				ClearStore();
			}
		}
	}
}
